//code 码字典设置
const codeMessage = {
  success:200,  //成功
  fail:500,  //失败
  loginLose:403,  //登录失效
  busy:401,  //服务器正忙
}


function getResult() { };
/**
 *
 * @param {*} result 返回值
 * @param {*} code  
 * @param {*} msg   文字描述
 * @param {*} msgCode
 * @returns
 */
getResult.prototype.success = function (message) {
  message || (message = {});
  return {
    Code: message.code || codeMessage.success,
    Result: message.Result || {},
    msg: message.msg || "请求成功",
    msgCode: message.msgCode || codeMessage.success,
  };
};

getResult.prototype.fail = function (message) {
  message || (message = {});
  return {
    Code: message.code || codeMessage.fail,
    Result: message.Result || {},
    msg: message.msg || "请求失败",
    msgCode: message.msgCode || codeMessage.fail,
  };
};

getResult.prototype.loginLose = function (message) { //登录失效
  message || (message = {});
  return {
    Code: message.code || codeMessage.loginLose,
    Result: message.Result || {},
    msg: message.msg || "登录失效请重新登录",
    msgCode: message.msgCode || codeMessage.loginLose,
  };
};

getResult.prototype.busy = function (message) {
  message || (message = {});
  return {
    Code: message.code || codeMessage.busy,
    Result: message.Result || {},
    msg: message.msg || "服务器正忙，请稍后再试",
    msgCode: message.msgCode || codeMessage.busy,
  };
};

module.exports = new getResult();